<?php

/**
 * Description of Image
 *
 * @author Kam
 */
class Application_Model_DbTable_Image extends My_Db_Table {

    protected $_name = 'image';
    protected $_primary = 'image_id';

    /**
     * 
     * @param string $sourceName
     * @param string|int $sourceId
     * @return Zend_Db_Table_Select
     */
    public function getBySource($sourceName, $sourceId = null) {
        $select = $this->select()
                ->where('source_name = ?', $sourceName)
                ->where('active = 1')
                ->order('image_id');
        if ($sourceId !== null) {
            $select->where('source_id = ?', $sourceId);
        }
        return $select;
    }

    protected function getMainCodeColumnName() {
        return 'code';
    }

}

